﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace EasyNet.Componets.Exceptions
{
    public class CustomException : Exception
    {
        protected CustomException()
        {
        }

        protected CustomException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
        
        public CustomException(string errorCode, string message) : base(message)
        {
            Init(errorCode, message);
        }

        public CustomException(string errorCode, string message, Exception innerException)
            : base(message, innerException)
        {
            Init(errorCode, message);
        }


        void Init(string errorCode, string message)
        {
            ErrorCode = errorCode;
            CustomMessage = string.Format("Code: {0} Message: {1}", errorCode, message);
           
        }

        /// <summary>
        /// 错误代码
        /// </summary>
        public string ErrorCode
        {
            get;
            private set;
        }
        
        public string CustomMessage { get; private set; }
    }
}
